package com.forezp.thinking.chapter15;

/**
 * Created by forezp on 2017/12/5.
 */
public class GenerateIdEntty {

    private static int count=1;
    private final int id=count++;

    public int getId() {
        return id;

    }

    public static void main(String[] args) {
        for(int i=0;i<300;i++) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(new GenerateIdEntty().getId());
                System.out.println(new GenerateIdEntty().getId());
                System.out.println(new GenerateIdEntty().getId());
                System.out.println(new GenerateIdEntty().getId());
                System.out.println(new GenerateIdEntty().getId());
                System.out.println(new GenerateIdEntty().getId());
                System.out.println(new GenerateIdEntty().getId());
            }
        }).start();
        }

    }
}
